﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BaseSet.Data;
using BaseSet.Logic;
using BaseSet.Entity;
using BaseSet.Framework;
using BaseSet.Entity.Common;
using BaseSet.Entity.Common.Text;
using BaseSet;
using System.Data;


namespace WebSite.UserSetting
{
    public partial class BankInfo : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                LoadContent();
            }
        }

        #region 保存
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string alipaynumber = txtAliPayNumber.Text.Trim();
            string bankname = txtBankName.Text.Trim();
            string openbankname = txtOpenBankName.Text.Trim();
            string bankaccountnumber = txtBankAccountNumber.Text.Trim();
            string bankaccountname = txtBankAccountName.Text.Trim();

            //if (!string.IsNullOrEmpty(bankaccountnumber))
            //{
            //    if (string.IsNullOrEmpty(bankname) || string.IsNullOrEmpty(openbankname) || string.IsNullOrEmpty(bankaccountnumber) || string.IsNullOrEmpty(bankaccountname))
            //    {
            //        Tools.Alert("所有信息都为必填");
            //        return;
            //    }
            //}
            Users uinfo = UserBase.GetCurrentUser();
            UsersHelper uhelper = new UsersHelper();

            uinfo.AliPayAccountNumber = alipaynumber;
            uinfo.BankName = bankname;
            uinfo.OpenBankName = openbankname;
            uinfo.BankAccountNumber = bankaccountnumber;
            uinfo.BankAccountName = bankaccountname;
            uinfo.BankEditDate = System.DateTime.Now;
            uhelper.EditUsers(uinfo);

            Tools.Alert("银行账号和支付宝账号信息更新成功");
            return;

        }
        #endregion

        #region 加载信息
        private void LoadContent()
        {
            Users uinfo = UserBase.GetCurrentUser();
            txtBankName.Text = uinfo.BankName;
            txtOpenBankName.Text = uinfo.OpenBankName;
            txtBankAccountNumber.Text = uinfo.BankAccountNumber;
            txtBankAccountName.Text = uinfo.BankAccountName;
            txtAliPayNumber.Text = uinfo.AliPayAccountNumber;
        }
        #endregion
    }
}